home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Codigo / Control del teclado / KeyExamineWithScroll / KeyExamineWithScroll.cs next >
Encoding:
Text File  |  2002-04-24  |  1.4 KB  |  50 lines

  1. //---------------------------------------------------
  2. // KeyExamineWithScroll.cs ⌐ 2001 by Charles Petzold
  3. //---------------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Runtime.InteropServices;
  7. using System.Windows.Forms;
  8.  
  9. class KeyExamineWithScroll: KeyExamine
  10. {
  11.      public new static void Main()
  12.      {
  13.           Application.Run(new KeyExamineWithScroll());
  14.      }
  15.      public KeyExamineWithScroll()
  16.      {
  17.           Text += " con desplazamiento";
  18.      }
  19.           // Definir una estructura rectßngulo como en Win32.
  20.  
  21.      [StructLayout(LayoutKind.Sequential)]
  22.      public struct RECT 
  23.      {
  24.           public int left;
  25.           public int top;
  26.           public int right;
  27.           public int bottom;
  28.      }
  29.           // Declarar la llamada a ScrollWindow.
  30.  
  31.      [DllImport("user32.dll")]
  32.      public static extern int ScrollWindow(IntPtr hwnd, int cx, int cy, 
  33.                                            ref RECT rectScroll,
  34.                                            ref RECT rectClip);
  35.  
  36.           // Redefinir el mΘtodo de KeyExamine.
  37.  
  38.      protected override void ScrollLines()
  39.      {
  40.           RECT rect;
  41.  
  42.           rect.left   = 0;
  43.           rect.top    = Font.Height;
  44.           rect.right  = ClientSize.Width;
  45.           rect.bottom = ClientSize.Height;
  46.     
  47.           ScrollWindow(Handle, 0, -Font.Height, ref rect, ref rect);
  48.      }
  49. }
  50.